package common.main.common;

import common.system.FileOperation;

public class BaseConfig {
    public static String mysqlHost = "localhost:3306";  //
    public static String mysqlDatabaseName = "junkewei";   //
    public static String mysqlUserName = "root";           //
    public static String mysqlPassword = "123456";     //
    public static String entranceUrl = null;

    //cnkiJournalPaperConfig  cnki中文期刊文章采集专用
    public static String journalName = null;


    public static void init(String filePath) {
        String content = FileOperation.read(filePath);//("config/cnkiConfig.txt");
        String[] lines = content.split("\n");

        for (String line : lines) {
            if (line.length() > 3 && !line.startsWith("#")) {
                line = line.trim();
                if (line.startsWith("mysqlHost")) {
                    mysqlHost = line.split("=")[1].trim();
                } else if (line.startsWith("mysqlDatabaseName")) {
                    mysqlDatabaseName = line.split("=")[1].trim();
                } else if (line.startsWith("mysqlUserName")) {
                    mysqlUserName = line.split("=")[1].trim();
                } else if (line.startsWith("mysqlPassword")) {
                    mysqlPassword = line.split("=")[1].trim();
                } else if (line.startsWith("entranceUrl")) {
                    entranceUrl = line.split("entranceUrl=")[1].trim();
                } else if(line.startsWith("journalName")){
                    journalName = line.split("journalName=")[1].trim();
                }
            }
        }
    }
}
